package com.partsoft.dits.message;

/**
 *TODO 需要实现序列化， 谁来补充？ 
 *消息异常
 */
public class MessageException extends Exception {
	
	private static final long serialVersionUID = 8309522606366920876L;
	
	private MessageEntity messageEntity;
	
	private byte[] xmlSource;
	
	/**
	 * 默认构造函数
	 */
	public MessageException() {
		super();
	}
	
	/**
	 * @param message 错误内容
	 */
	public MessageException(String message) {
		this(message, (byte[])null);
	}

	/**
	 * @param message 错误内容
	 * @param xmlSource 原始XML
	 */
	public MessageException(String message, byte[] xmlSource) {
		this(message, null, xmlSource);
	}

	/**
	 * @param entity 消息实体
	 */
	public MessageException(MessageEntity entity) {
		this(entity, (byte[])null);
	}
	
	/**
	 * @param entity 消息实体
	 * @param xmlSource 原始XML
	 */
	public MessageException(MessageEntity entity, byte[] xmlSource) {
		super();
		this.messageEntity = entity;
		this.xmlSource = xmlSource;
	}
	

	/**
	 * @param message 错误内容
	 * @param entity 错误节点
	 */
	public MessageException(String message, MessageEntity entity) {
		this(message, entity, (byte[])null);
	}
	
	/**
	 * @param message 错误内容
	 * @param entity 消息实体
	 * @param xmlSource 原始XML
	 */
	public MessageException(String message, MessageEntity entity, byte[] xmlSource) {
		super(message);
		this.messageEntity = entity;
		this.xmlSource = xmlSource;
	}
	
	
	/**
	 * @param message 错误内容
	 * @param entity 消息实体
	 * @param e  级联异常
	 */
	public MessageException(String message, MessageEntity entity, Throwable e) {
		this(message, entity, null, e);
	}
	
	/**
	 * @param message 错误内容
	 * @param xmlSource 原始XML
	 * @param e 级联错误
	 */
	public MessageException(String message, byte[] xmlSource, Throwable e) {
		this(message, null, xmlSource, e);
	}
	
	
	/**
	 * @param message 错误内容
	 * @param entity 消息实体
	 * @param xmlSource 原始XML
	 * @param e 级联异常
	 */
	public MessageException(String message, MessageEntity entity, byte[] xmlSource, Throwable e) {
		super(message, e);
		this.messageEntity = entity;
		this.xmlSource = xmlSource;
	}
	
	/**
	 * @param entity 消息实体
	 * @param xmlSource 原始XML
	 * @param e 级联异常
	 */
	public MessageException(MessageEntity entity, byte[] xmlSource, Throwable e) {
		super(e);
		this.messageEntity = entity;
		this.xmlSource = xmlSource;
	}

	/**
	 * @param entity 消息实体
	 * @param e 原始XML
	 */
	public MessageException(MessageEntity entity, Throwable e) {
		super(e);
		this.messageEntity = entity;
	}
	
	/**
	 * @param message 错误消息
	 * @param e 级联异常
	 */
	public MessageException(String message, Throwable e) {
		super(message, e);
	}
	
	/**
	 * @param e 级联异常
	 */
	public MessageException(Throwable e) {
		super(e);
	}
	
	/**
	 * @return 消息实体
	 */
	public MessageEntity getMessageEntity() {
		return messageEntity;
	}
	
	/**
	 * 原始XML字节
	 */
	public byte[] getXmlSource() {
		return xmlSource;
	}

}
